package com.zhanghe.study.feign.fallback;

import com.zhanghe.study.feign.DeptClient;
import com.zhanghe.study.model.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author zh
 * @date 2021/8/24 10:36
 */
@Component
public class DeptClientFallBackFactory implements FallbackFactory<DeptClient> {

    @Override
    public DeptClient create(Throwable throwable) {
        return new DeptClient() {
            @Override
            public Dept get(long id) {
                Dept dept = new Dept();
                dept.setDeptNo(id);
                dept.setdName("信息不存在fallback");
                return dept;
            }
        };
    }
}
